package com.dletc.domain;

import java.sql.Timestamp;
import java.util.Date;
import java.util.List;

public class Order {
    private int OrderID;
    private int UserID;
    private int IsDown;
    private Timestamp OrderTime;
    private List<Dish> list;

    //处理时间戳精度到秒
    {
        Date date = new Date();
        long gettime =date.getTime() / 1000 * 1000;
        date.setTime(gettime);
        Timestamp ts = new Timestamp(date.getTime());
        OrderTime = ts;
    }

    public Order() {
    }

    public Order(int userID, int isDown, Timestamp orderTime, List<Dish> list) {
        UserID = userID;
        IsDown = isDown;
        OrderTime = orderTime;
        this.list = list;
    }

    //OrderID自增不用赋值
    public Order(int userID, int isDown, Timestamp orderTime) {
        UserID = userID;
        IsDown = isDown;
        OrderTime = orderTime;
    }

    public Order(int userID, int isDown, List<Dish> list) {
        UserID = userID;
        IsDown = isDown;
        this.list = list;
    }

    public int getOrderID() {
        return OrderID;
    }

    public void setOrderID(int orderID) {
        OrderID = orderID;
    }

    public int getUserID() {
        return UserID;
    }

    public void setUserID(int userID) {
        UserID = userID;
    }

    public int getIsDown() {
        return IsDown;
    }

    public void setIsDown(int isDown) {
        IsDown = isDown;
    }

    public Timestamp getOrderTime() {
        return OrderTime;
    }

    public void setOrderTime(Timestamp orderTime) {
        OrderTime = orderTime;
    }

    public List<Dish> getList() {
        return list;
    }

    public void setList(List<Dish> list) {
        this.list = list;
    }

    @Override
    public String toString() {
        return isNull(UserID)+ "\t" + isNull(OrderID)+ "\t" + isNull(IsDown)+ "\t" + isNull(OrderTime)+ "\t" + list;
    }

    public Object isNull(Object object){
        if (object == null){
            return ""; //为空时候设定为字符串的空
        }
        return object;
    }
}
